 package CurtainDesign;

 import CurtainDesign.utils.CurtainChecker;
 import com.sun.jimi.core.Jimi;
 import java.awt.BorderLayout;
 import java.awt.Component;
 import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.HeadlessException;
 import java.awt.event.WindowEvent;
 import java.util.List;
 import javax.swing.JFrame;
 import javax.swing.JOptionPane;

 public class MainView extends JFrame
 {
   static OrderInfo m_OrderInfo = null;
   static List marksList = null;
   static int markIndex = 0;
   static MenuView m_MenuView = null;
   static NaviView m_NaviView = new NaviView();
   static OrderInfoView m_OrderView = null;
   static ShippingMarkPrintView m_PrintMarkView = null;
   static SelectStyleView m_SelectStyleView = new SelectStyleView();
   protected String m_SelectStyle = "";

   public MainView() throws HeadlessException {
     enableEvents(64L);
     try
     {
//       Thread CheckLicense = new Thread(new License(), "检查License");
//       CheckLicense.start();

       Init();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }

   public void Init() throws Exception {
     setSize(new Dimension(820, 600));

     setTitle("欣成木业透气窗计算软件 Version 3.0 试用版");
     setIconImage(Jimi.getImage("images/logo.bmp"));

     getContentPane().setLayout(new BorderLayout());
     getContentPane().add(m_NaviView, "West");
     getContentPane().add(m_SelectStyleView, "Center");
   }

   protected void processWindowEvent(WindowEvent e)
   {
     super.processWindowEvent(e);
     if (e.getID() == 201) {
       dispose();
       m_OrderView = null;
       m_MenuView = null;
       m_NaviView = null;
       m_SelectStyleView = null;
       this.m_SelectStyle = null;
       System.exit(0);
     }
   }

   public void SwitchWindow(String Todo)
   {
     getContentPane().removeAll();
     if (Todo.equals(Constants.TODO[0]))
     {
       if (m_SelectStyleView == null) {
         m_SelectStyleView = new SelectStyleView();
       }
       getContentPane().add(m_NaviView, "West");
       getContentPane().add(m_SelectStyleView, "Center");
     }
     else if (Todo.equals(Constants.TODO[1]))
     {
       if (this.m_SelectStyle.equals(Constants.STYLES[0])) {
         CurtainDesign.m_orderfile = null;
         CurtainDesign.m_orderfile = new OrderFileRectSimple();

         if (m_SelectStyleView.IsStyleChanged()) {
           m_OrderInfo = null;
           m_OrderInfo = new OrderInfoRectSimple();
           m_SelectStyleView.SetStyleChanged(false);
         }
         m_OrderView = null;
         m_OrderView = new OrderInfoRectSimpleView();
         ((OrderInfoRectSimpleView)m_OrderView).CheckCalcBt();
       } else if (this.m_SelectStyle.equals(Constants.STYLES[1])) {
         CurtainDesign.m_orderfile = null;
         CurtainDesign.m_orderfile = new OrderFileByFold();

         if (m_SelectStyleView.IsStyleChanged()) {
           m_OrderInfo = null;
           m_OrderInfo = new OrderInfoByFold();
           m_SelectStyleView.SetStyleChanged(false);
         }
         m_OrderView = null;
         m_OrderView = new OrderInfoByFoldView();
         ((OrderInfoByFoldView)m_OrderView).CheckCalcBt();
       }
       else if (this.m_SelectStyle.equals(Constants.STYLES[2])) {
         CurtainDesign.m_orderfile = null;
         CurtainDesign.m_orderfile = new OrderFileByPass();

         if (m_SelectStyleView.IsStyleChanged()) {
           m_OrderInfo = null;
           m_OrderInfo = new OrderInfoByPass();
           m_SelectStyleView.SetStyleChanged(false);
         }
         m_OrderView = null;
         m_OrderView = new OrderInfoByPassView();
         ((OrderInfoByPassView)m_OrderView).CheckCalcBt();
       }
       else
       {
         m_OrderInfo = null;
         m_OrderInfo = new OrderInfoDefault();
         m_OrderView = null;
         m_OrderView = new OrderInfoDefaultView();
       }
       getContentPane().add(m_NaviView, "West");
       getContentPane().add(m_OrderView, "Center");
     }
     else if (!Todo.equals(Constants.TODO[2]))
     {
       if (!Todo.equals(Constants.TODO[3]))
       {
         if (Todo.equals(Constants.TODO[4]))
         {
           getContentPane().add(m_NaviView, "West");
           marksList = null;
           m_PrintMarkView = null;
           // 输出唛头
           m_PrintMarkView = new ShippingMarkPrintView();
           getContentPane().add(m_PrintMarkView, "Center");
         }
       }
     }

     repaint();
     setVisible(true);
   }

   public String GetCurrentViewName()
   {
     return getContentPane().getComponent(1).getName();
   }

   public void EnableCalcBt()
   {
     m_NaviView.EnableCalcBt();
   }

   public void DisableCalcBt() {
     m_NaviView.DisableCalcBt();
   }

   public void EnableNewBt() {
     m_NaviView.EnableNewBt();
   }

   public void DisableNewBt() {
     m_NaviView.DisableNewBt();
   }

   public void EnableSaveAsBt() {
     m_NaviView.EnableSaveAsBt();
   }

   public void DisableSaveAsBt() {
     m_NaviView.DisableSaveAsBt();
   }

   public void EnableSaveBt() {
     m_NaviView.EnableSaveBt();
   }

   public void DisableSaveBt() {
     m_NaviView.DisableSaveBt();
   }

   public void EnableOpenBt() {
     m_NaviView.EnableOpenBt();
   }

   public void DisableOpenBt() {
     m_NaviView.DisableOpenBt();
   }

   public void enablePrintShippingMark()
   {
     m_NaviView.enablePrintShippingMark();
   }

   public void DisablePrintShippingMark()
   {
     m_NaviView.DisablePrintShippingMark();
   }

   public String GetSelectStyle() {
     return this.m_SelectStyle;
   }

   public void SetSelectStyle(String stylename) {
     this.m_SelectStyle = stylename;
   }

   public OrderInfo GetOrderInfo() {
     return m_OrderInfo;
   }

   public List getMarkList()
   {
     return marksList;
   }

   public boolean IsStyleExist(String style) {
     for (int i = 0; i < Constants.STYLES.length; i++) {
       if (style.equals(Constants.STYLES[i])) {
         return true;
       }
     }
     return false;
   }

   public int GetSelectStyleInt() {
     for (int i = 0; i < Constants.STYLES.length; i++) {
       if (this.m_SelectStyle.equals(Constants.STYLES[i])) {
         return i;
       }
     }
     return -1;
   }

   public void SwitchWindow(String WindowType, String OrderFilePath) {
     getContentPane().removeAll();

     CurtainDesign.m_UserMainGUI.DisablePrintShippingMark();

     if (m_SelectStyleView.IsStyleChanged()) {
       m_SelectStyleView.SetStyleChanged(false);
     }
     CurtainDesign.m_orderfile = null;
     m_OrderInfo = null;
     m_OrderView = null;

     for (int i = 0; (i < Constants.STYLES_EN.length) && (!CurtainChecker.isEmpty(WindowType)); i++) {
       if (WindowType.trim().equalsIgnoreCase(Constants.STYLES_EN[i])) {
         WindowType = Constants.STYLES[i];
         CurtainDesign.m_UserMainGUI.SetSelectStyle(WindowType);
       }
     }
     if (WindowType.equals(Constants.STYLES[0])) {
       CurtainDesign.m_orderfile = new OrderFileRectSimple();

       m_OrderInfo = new OrderInfoRectSimple();
       CurtainDesign.m_orderfile.ReadOrderFile(OrderFilePath);
       m_OrderView = new OrderInfoRectSimpleView();
       ((OrderInfoRectSimpleView)m_OrderView).CheckCalcBt();
     } else if (WindowType.equals(Constants.STYLES[1])) {
       CurtainDesign.m_orderfile = new OrderFileByFold();

       m_OrderInfo = new OrderInfoByFold();
       CurtainDesign.m_orderfile.ReadOrderFile(OrderFilePath);
       m_OrderView = new OrderInfoByFoldView();
       ((OrderInfoByFoldView)m_OrderView).CheckCalcBt();
     }
     else if (WindowType.equals(Constants.STYLES[2])) {
       CurtainDesign.m_orderfile = new OrderFileByPass();

       m_OrderInfo = new OrderInfoByPass();
       CurtainDesign.m_orderfile.ReadOrderFile(OrderFilePath);
       m_OrderView = new OrderInfoByPassView();
       ((OrderInfoByPassView)m_OrderView).CheckCalcBt();
     }
     else
     {
       m_OrderInfo = new OrderInfoDefault();
       m_OrderView = new OrderInfoDefaultView();
       JOptionPane.showMessageDialog(null, "窗户类型错误，不能打开", "错误", 0);
     }

     getContentPane().add(m_NaviView, "West");
     getContentPane().add(m_OrderView, "Center");

     repaint();
     setVisible(true);
   }
 }

/* Location:           C:\Users\Administrator\Desktop\奥特百叶窗\Shutter DesignerV3.1\CurtainDesign.jar
 * Qualified Name:     CurtainDesign.MainView
 * JD-Core Version:    0.6.0
 */